<?php
global $_W, $_GPC;
$weid = $this->_weid;
$action = 'wxappsetting';
$title = '小程序设置';
$GLOBALS['frames'] = $this->getMainMenu();
$config = $this->module['config']['weisrc_dish'];
load()->func('tpl');

$sysaccount = pdo_fetch("select * from " . tablename('account') . " WHERE uniacid=:uniacid LIMIT 1", array
(':uniacid'
    => $_W['uniacid']));

$wxsetting = pdo_fetch("SELECT * FROM " . tablename('weisrc_dish_wxappsetting') . " where weid = :weid LIMIT 1", array(':weid' => $this->_weid));
if (checksubmit('submit')) {
    $data = array(
        'weid' => $_W['uniacid'],
        'wxappid' => trim($_GPC['wxappid']),
        'bartitle' => trim($_GPC['bartitle']),
        'wxappweid' => intval($_GPC['wxappweid']),
        'storeid' => intval($_GPC['storeid']),
        'dateline' => TIMESTAMP,
    );
    if (empty($wxsetting)) {
        pdo_insert('weisrc_dish_wxappsetting', $data);
    } else {
        unset($data['dateline']);
        pdo_update('weisrc_dish_wxappsetting', $data, array('weid' => $_W['uniacid']));
    }
    message('操作成功', $this->createWebUrl('wxappsetting'), 'success');
}

include $this->template('web/wxappsetting');

